<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>详情页</title>
    <style>
        li{
            background: skyblue;
        }
    </style>
</head>
<body>
    <ul class="list">
        
    </ul>

    <script>
        // 截取参数
        let idx = location.search.substring(1).split('=')[1];
        let list = document.querySelector('.list');

        // 发送请求
        let xhr = new XMLHttpRequest();
        xhr.open('get','http://localhost:2003/gooditem/'+idx,true)
        xhr.send();

        // 处理响应
        xhr.onload = () =>{
            // 解析
            let data = JSON.parse(xhr.responseText)[0];

            // 渲染
            list.innerHTML = `
                <li idx="${data.id}">
                    <h3>${data.name}</h3>
                    <p>${data.price}</p>
                </li>
            `;
        }
    </script>
</body>
</html>